
{include file="/public/header"}

<div class="layui-fluid">
    <div class="layui-card">

        <div class="layui-card-body images" style="background-image: url('https://bing.ioliu.cn/v1/rand?h=70');">
            <img style="border-radius:50%;width:50px;height:50px;" src="{__IMG__}logo.png" alt="SF"/>
            <b id="SF_title" style="color:#fff;font-size: 18px">SF授权系统</b>
            <span id="tip" class="pull-right">
                <i class="sf-avatar sf-avatar-icon sf-avatar-small layui-icon layui-icon-help" style="position: relative;top: 12px;color: rgb(255, 169, 64); background-color: rgb(255, 247, 230);"></i>
            </span>
        </div>
        <div class="layui-card-body layui-form">
            <div class="layui-tab layui-steps layui-steps-readonly" lay-filter="stepsDemoForget"
                 style="max-width: 1000px;">
                <ul class="layui-tab-title">
                    <li class="layui-this">
                        <i class="layui-icon layui-icon-ok">1</i>
                        <span class="layui-steps-title">第一步</span>
                        <span class="layui-steps-content">同意服务协议</span>
                    </li>
                    <li>
                        <i class="layui-icon layui-icon-ok">2</i>
                        <span class="layui-steps-title">第二步</span>
                        <span class="layui-steps-content">检查安装环境</span>
                    </li>
                    <li>
                        <i class="layui-icon layui-icon-ok">3</i>
                        <span class="layui-steps-title">第三步</span>
                        <span class="layui-steps-content">填写数据库信息</span>
                    </li>
                    <li>
                        <i class="layui-icon layui-icon-ok">4</i>
                        <span class="layui-steps-title">第四步</span>
                        <span class="layui-steps-content">创建数据表</span>
                    </li>
                    <li>
                        <i class="layui-icon layui-icon-ok">5</i>
                        <span class="layui-steps-title">第五步</span>
                        <span class="layui-steps-content">填写站点信息</span>
                    </li>
                    <li>
                        <i class="layui-icon layui-icon-ok">6</i>
                        <span class="layui-steps-title">第六步</span>
                        <span class="layui-steps-content">完成安装</span>
                    </li>
                </ul>
                <div class="layui-tab-content">
                    <div class="layui-tab-item layui-show">
                        <form class="layui-form layui-form-pane">
                            <div class="layui-tab layui-tab-brief">
                                <ul class="layui-tab-title">
                                    <li class="layui-this">服务协议</li>
                                    <li>更新记录</li>
                                    <li>授权代码</li>
                                    <li>关于我们</li>
                                </ul>
                                <div class="layui-tab-content">
                                    <div class="layui-tab-item layui-show" id="divLoading"><iframe style="width:100%;height:400px;border: 1px solid #fff ;" src="{:url('/Index/userAgreen')}"></iframe></div>
                                    <div class="layui-tab-item"><iframe style="width:100%;height:400px;border: 1px solid #fff ;" src="{:url('/Index/updateLog')}"></iframe></div>
                                    <div class="layui-tab-item"><iframe style="width:100%;height:400px;border: 1px solid #fff ;" src="{:url('/Index/userAgreen')}"></iframe></div>
                                    <div class="layui-tab-item">
                                        <div class="layui-col-sm12 layui-col-md12">
                                            <div class="layui-card">
                                                <div class="layui-card-body" style="padding: 25px;">
                                                    <div class="text-center layui-text">
                                                        <div class="user-info-head" id="userInfoHead">
                                                            <img src="//q4.qlogo.cn/headimg_dl?dst_uin=2129876388&amp;spec=100" alt=""/>
                                                        </div>
                                                        <h2 style="padding-top: 20px;">陌上花开</h2>
                                                        <p style="padding-top: 8px;">花开的再灿烂，也有凋谢的一天，致我们过去的青春</p>
                                                    </div>
                                                    <div class="layui-text" style="padding-top: 30px;">
                                                        <div class="user-info-list-item">
                                                            <i class="layui-icon layui-icon-username"></i>
                                                            <p>QQ:2129876388</p>
                                                        </div>
                                                        <div class="user-info-list-item">
                                                            <i class="layui-icon layui-icon-app"></i>
                                                            <p>SF-全力打造最好的授权系统</p>
                                                        </div>
                                                        <div class="user-info-list-item">
                                                            <i class="layui-icon layui-icon-location"></i>
                                                            <p>河北省沧州市</p>
                                                        </div>
                                                    </div>
                                                    <div class="layui-line-dash"></div>
                                                    <h3>标签</h3>
                                                    <div class="layui-badge-list" style="padding-top: 6px;">
                                                        <span class="layui-badge layui-badge-red">很有想法的</span>
                                                        <span class="layui-badge layui-badge-orange">专注设计</span>
                                                        <span class="layui-badge layui-badge-yellow">强迫症</span>
                                                        <span class="layui-badge layui-badge-green">懒</span>
                                                        <span class="layui-badge layui-badge-blue">热爱编程</span>
                                                        <span class="layui-badge layui-badge-purple">hhhc</span>
                                                    </div>
                                                </div>
                                            </div>
                                        </div>
                                        <div class="layui-col-sm12 layui-col-md12">
                                            <div class="layui-card">
                                                <div class="layui-card-body" style="padding: 25px;">
                                                    <div class="text-center layui-text">
                                                        <div class="user-info-head" id="userInfoHead">
                                                            <img src="//q4.qlogo.cn/headimg_dl?dst_uin=869998889&amp;spec=100" alt=""/>
                                                        </div>
                                                        <h2 style="padding-top: 20px;">世外云计算</h2>
                                                        <p style="padding-top: 8px;"><a target="_blank" href="https://www.shiwaiyun.com/" style="text-decoration: none;font-weight: 700;">www.shiwaiyun.com</a> 企业级云服务器，品牌成立于2016年，拥有多年云计算经验，使用本授权系统<font style="color:#ff0000">免费领取8核8G云主机一月!</font></p>
                                                    </div>
                                                    <div class="layui-text" style="padding-top: 30px;">
                                                        <div class="user-info-list-item">
                                                            <i class="layui-icon layui-icon-username"></i>
                                                            <p>QQ:869998889</p>
                                                        </div>
                                                        <div class="user-info-list-item">
                                                            <i class="layui-icon layui-icon-app"></i>
                                                            <p>世外云-企业级云服务器</p>
                                                        </div>
                                                        <div class="user-info-list-item">
                                                            <i class="layui-icon layui-icon-location"></i>
                                                            <p>河北省保定市</p>
                                                        </div>
                                                    </div>
                                                    <div class="layui-line-dash"></div>
                                                    <h3>标签</h3>
                                                    <div class="layui-badge-list" style="padding-top: 6px;">
                                                        <span class="layui-badge layui-badge-red">云服务器</span>
                                                        <span class="layui-badge layui-badge-orange">域名注册</span>
                                                        <span class="layui-badge layui-badge-yellow">云虚拟主机</span>
                                                        <span class="layui-badge layui-badge-green">物理服务器</span>
                                                        <span class="layui-badge layui-badge-blue">机房托管业务</span>
                                                        <span class="layui-badge layui-badge-purple">短信发送服务</span>
                                                    </div>
                                                </div>
                                            </div>
                                        </div>


                                    </div>
                                </div>
                            </div>
                            <div id="id" class="layui-form-item">
                                <input type="checkbox" name="agreen" id="agreen" value="agreen_SF" lay-skin="primary"  title="我已同意服务协议"/></div>
                            <button class="layui-btn layui-btn-fluid layui-btn-radius"
                                    lay-filter="stepDemoFormSubmit1" lay-submit>开始安装
                            </button>
                        </form>
                    </div>
                    <div class="layui-tab-item text-center" id="divLoading2">
                        <div class="demo-cp-item" style="padding-top:15px;height:100px">
                            <div id="SF_Progress"></div>
                        </div>
                        <div id="loading"></div>
                        <div id="sfhtml"></div>

                        <div id="stepButton" style="display: none;margin-top: 20px;">
                            <button data-steps="prev" type="button" align="left" style="width:45%;" class="layui-btn layui-btn-primary layui-btn-fluid layui-btn-radius">上一步
                            </button>
                            <button class="layui-btn layui-btn-radius" align="right" style="width:45%;" lay-filter="stepDemoFormSubmit2" lay-submit>下一步
                            </button>
                        </div>
                    </div>
                    <div class="layui-tab-item layui-form-pane" id="divLoading3">
                        <form class="layui-form layui-form-pane" id="formBasForm" lay-filter="formBasForm">
                            <div class="layui-form-item">
                                <label class="layui-form-label">数据库地址</label>
                                <div class="layui-input-block">
                                    <input type="text" name="hostname" value="localhost" class="layui-input"  placeholder="数据库的地址" autocomplete="off" required/>
                                </div></div>
                            <div class="layui-form-item">
                                <label class="layui-form-label">数据库端口</label>
                                <div class="layui-input-block">
                                    <input type="number" name="hostport" value="3306" class="layui-input" placeholder="数据库的端口" autocomplete="off" required/>
                                </div></div>
                            <div class="layui-form-item">
                                <label class="layui-form-label">数据库账号</label>
                                <div class="layui-input-block">
                                    <input type="text" name="username" value="" class="layui-input" placeholder="数据库的登录用户名" autocomplete="off" required/>
                                </div></div>
                            <div class="layui-form-item">
                                <label class="layui-form-label">数据库密码</label>
                                <div class="layui-input-block">
                                    <input type="password" name="password" value="" class="layui-input" placeholder="数据库的登录密码" autocomplete="off" required/>
                                </div></div>
                            <div class="layui-form-item">
                                <label class="layui-form-label">数据库库名</label>
                                <div class="layui-input-block">
                                    <input type="text" name="database" value="" class="layui-input" placeholder="数据库的库名" autocomplete="off" required/>
                                </div></div>

                            <div class="text-center">
                                <button data-steps="prev" type="button" align="left" style="width:45%;" class="layui-btn layui-btn-primary layui-btn-fluid layui-btn-radius">上一步
                                </button>
                                <button class="layui-btn layui-btn-radius" align="right" style="width:45%;" lay-filter="stepDemoFormSubmit3" lay-submit>下一步
                                </button>
                            </div>
                        </form>
                    </div>
                    <div class="layui-tab-item" id="divLoading4">
                        <div class="layui-container">
                            <div id="mysql_old" style="display: none">
                                <div class="layui-row layui-col-space20">
                                    <div class="layui-col-md12">
                                        <blockquote class="layui-elem-quote-sf-info">
                                            系统检测到你已安装过SF授权系统
                                        </blockquote>
                                    </div>
                                    <div class="layui-col-md4">
                                        <button data-steps="prev" type="button" class="layui-btn layui-btn-primary layui-btn-fluid layui-btn-radius">上一步
                                        </button>
                                    </div>
                                    <div class="layui-col-md4">
                                        <button class="layui-btn layui-btn-SF-green layui-btn-fluid layui-btn-radius" lay-filter="jump_install" lay-submit>跳过安装
                                        </button>
                                    </div>
                                    <div class="layui-col-md4">
                                        <button class="layui-btn layui-btn-fluid layui-btn-warm layui-btn-radius" lay-filter="must_install" lay-submit>强制重新安装
                                        </button>
                                    </div>
                                </div>
                            </div>
                            <div id="mysql_new" style="display: none">
                                <div class="layui-row layui-col-space20">
                                    <div class="layui-col-md6">
                                        <button data-steps="prev" type="button" class="layui-btn layui-btn-primary layui-btn-fluid layui-btn-radius">上一步
                                        </button>
                                    </div>
                                    <div class="layui-col-md6">
                                        <button class="layui-btn layui-btn-fluid layui-btn-radius" lay-filter="mysql_install" lay-submit>创建数据表
                                        </button>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="layui-tab-item" id="divLoading5">
                        <form class="layui-form layui-form-pane" id="adminForm" lay-filter="adminForm">
                            <div class="layui-tab layui-tab-brief">
                                <ul class="layui-tab-title">
                                    <li class="layui-this">站长信息</li>
                                    <li>站点配置</li>
                                    <li>安全配置</li>
                                </ul>
                                <div class="layui-tab-content">
                                    <div class="layui-tab-item layui-show">
                                        <div class="layui-form-item">
                                            <label class="layui-form-label">管理员账号</label>
                                            <div class="layui-input-block">
                                                <input type="text" name="admin_username" value="admin" class="layui-input"  placeholder="登录后台的账号" lay-required/>
                                            </div>
                                        </div>
                                        <div class="layui-form-item">
                                            <label class="layui-form-label">管理员密码</label>
                                            <div class="layui-input-block">
                                                <input type="password" name="admin_password" value="123456" class="layui-input" placeholder="登录后台的密码" autocomplete="off" lay-required/>
                                            </div>
                                        </div>
                                        <div class="layui-form-item">
                                            <label class="layui-form-label">管理员ＱＱ</label>
                                            <div class="layui-input-block">
                                                <input type="number" name="admin_qq" value="" class="layui-input" placeholder="管理员的QQ" lay-required/>
                                            </div>
                                        </div>
                                        <div class="layui-form-item">
                                            <label class="layui-form-label">管理员邮箱</label>
                                            <div class="layui-input-block">
                                                <input type="text" name="admin_email" value="" class="layui-input" placeholder="管理员的邮箱" lay-required/>
                                            </div>
                                            <blockquote class="layui-elem-quote-sf-warning">请填写您的邮箱,用于登录后台</blockquote>
                                        </div>
                                        <hr/><i class="layui-icon layui-icon-tips"></i> 安装后可登录后台配置更多信息~
                                    </div>
                                    <div class="layui-tab-item">
                                        <div class="layui-form-item">
                                            <label class="layui-form-label">站点名称</label>
                                            <div class="layui-input-block">
                                                <input type="text" name="sitename" value="SF系统授权中心" class="layui-input" placeholder="该站点的名称" lay-required/>
                                            </div>
                                        </div>
                                        <hr/><i class="layui-icon layui-icon-tips"></i> 安装后可登录后台配置更多信息~
                                    </div>
                                    <div class="layui-tab-item">
                                        <div class="layui-form-item">
                                            <label class="layui-form-label">后台入口</label>
                                            <div class="layui-input-block">
                                                <input type="text" name="login_address" value="admin" class="layui-input"  placeholder="留空则默认为admin.php"/>
                                            </div>
                                            <blockquote class="layui-elem-quote-sf-warning">
                                                默认为admin.php，只填文件名即可，不带php后缀
                                            </blockquote>
                                        </div>
                                        <div class="layui-form-item">
                                            <label class="layui-form-label">登陆口令</label>
                                            <div class="layui-input-block">
                                                <input type="text" name="SF_LOGIN_KEY" value="" class="layui-input"  placeholder="留空则不验证口令"/>
                                            </div>
                                            <blockquote class="layui-elem-quote-sf-warning">
                                                登陆后台所需的口令，留空则不需要验证口令<br><br>若口令为：123456<br>
                                                登陆示例：{:DOMAIN}/后台入口?123456
                                            </blockquote>
                                        </div>
                                        <button type="button" id="binding" class="layui-btn layui-btn-warm layui-btn-fluid layui-btn-radius">点击绑定QQ快捷登陆
                                        </button>
                                        <hr/><i class="layui-icon layui-icon-tips"></i> 安装后可登录后台配置更多信息~
                                    </div>
                                </div>
                            </div>
                            <div class="text-center">
                                <button data-steps="prev" type="button" align="left" style="width:45%;" class="layui-btn layui-btn-primary layui-btn-fluid layui-btn-radius">上一步
                                </button>
                                <button class="layui-btn layui-btn-radius" align="right" style="width:45%;" lay-filter="admin_info" lay-submit>保存信息
                                </button>
                            </div>
                        </form>
                    </div>
                    <div class="layui-tab-item text-center" id="divLoading6">
                        <i class="layui-icon layui-icon-ok layui-circle"
                           style="background: #52C41A;color: #fff;font-size:30px;font-weight:bold;padding: 20px;line-height: 80px;"></i>
                        <div style="font-size: 24px;color: #333;margin-top: 30px;">安装成功</div>
                        <div style="font-size: 14px;color: #666;margin-top: 20px;">欢迎使用SF授权系统！</div>
                        <div style="text-align: center;margin: 50px 0 25px 0;">
                            <button align="left" style="width:45%;" class="layui-btn layui-btn-primary layui-btn-fluid layui-btn-radius" lay-filter="SFindex" lay-submit>网站首页
                            </button>
                            <button class="layui-btn layui-btn-radius" align="right" style="width:45%;" lay-filter="loginadmin" lay-submit>登录后台
                            </button>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>

{include file="/public/footer"}
<script>
    layui.use(['layer', 'steps', 'form', 'admin', 'notice', 'CircleProgress'], function () {
        var $ = layui.jquery;
        var layer = layui.layer;
        var steps = layui.steps;
        var form = layui.form;
        var admin = layui.admin;
        var notice = layui.notice;
        var CircleProgress = layui.CircleProgress;
        $("#binding").click(function (){
            window.open("{:url('/Social/binding')}");
        });
        // 填写手机号
        form.on('submit(stepDemoFormSubmit1)', function (data) {
            admin.showLoading('#divLoading', 3, '.8');
            admin.btnLoading('[lay-filter="stepDemoFormSubmit1"]');
            setTimeout(function () {
                var chk_value = [];
                $('input[name="agreen"]:checked').each(function () {
                    chk_value.push($(this).val());
                });
                if (chk_value == ""){
                    admin.removeLoading('#divLoading', true, true);
                    admin.btnLoading('[lay-filter="stepDemoFormSubmit1"]', false);
                    notice.msg('请先同意服务协议！', {icon: 3,audio:'1'});
                    layer.tips('请先勾选该选项！', '#id', {
                        tips: [1,'#1890ff']
                    });
                    return false;
                }else{
                    admin.removeLoading('#divLoading', true, true);
                    admin.btnLoading('[lay-filter="stepDemoFormSubmit1"]', false);
                    steps.next('stepsDemoForget');
                    $('#SF_title').html('环境检测');
                    $('#loading').html('<h2 style="padding-top:20px"><b>检测环境中<span id="loginload">.</span></b></h2>');
                    var loadnum = 1;

                    setInterval(function (){
                        let load = '.';
                        if (loadnum == 1) {
                            load = '.';
                            loadnum += 1;
                        } else if (loadnum == 2){
                            load = '..';
                            loadnum += 1;
                        }else{
                            load = '...';
                            loadnum = 1;
                        }
                        $('#loginload').html(load);
                    },300);
                    $.ajax({
                        type: "POST",
                        url: "{:url('/Ajax/check')}",
                        dataType: "json",
                        success: function(data) {
                            if (data.code == 0) {
                                var ins10 = new CircleProgress('#SF_Progress', {
                                    max: 100,
                                    value: 0,
                                    textFormat: function (value, max) {
                                        return value + '分';
                                    }
                                });
                                var htmlarr = [];
                                htmlarr.push('<table class="layui-table sf-table" lay-skin="line"><thead><tr><th style="text-align: center;"><b>状况</b></th><th style="text-align: center;"><b>详情</b></th></tr></thead>');
                                $.each(data.data.check_msg.success, function(){
                                    htmlarr.push('<tr><td><span class="layui-badge layui-badge-green">支&emsp;持</span></td><td>'+ this +'</td></tr>');
                                });
                                $.each(data.data.check_msg.error, function(){
                                    htmlarr.push('<tr><td><span class="layui-badge layui-badge-orange">不支持</span></td><td>'+ this +'</td></tr>');
                                });
                                htmlarr.push('</table>');
                                var html = htmlarr.join("");
                                var timer10 = setInterval(function () {
                                    if(data.data.safe >= ins10.value){
                                        ins10.value += 1;
                                        if (ins10.value == ins10.max) {
                                            $('#SF_Progress').addClass('circle-progress-success');
                                            $('#loading').html('');
                                            $('#sfhtml').html(html);
                                            clearInterval(timer10);
                                            notice.msg('检测完成，该环境可以继续安装！', {icon: 1,audio:'1'});
                                            $("#stepButton").css('display','inherit');
                                        }
                                    } else {
                                        if (ins10.value == ins10.max) {
                                            $('#SF_Progress').addClass('circle-progress-success');
                                            $('#loading').html('');
                                            $('#sfhtml').html(html);
                                            clearInterval(timer10);
                                            notice.msg('检测完成，该环境可以继续安装！', {icon: 1,audio:'1'});
                                            $("#stepButton").css('display','inherit');
                                        }else if(data.data.safe>=90){
                                            $('#SF_Progress').addClass('circle-progress-info');
                                            $('#loading').html('');
                                            $('#sfhtml').html(html);
                                            clearInterval(timer10);
                                            notice.msg('检测完成，该环境请谨慎安装！', {icon: 3,audio:'1'});
                                            $("#stepButton").css('display','inherit');
                                        } else {
                                            $('#SF_Progress').addClass('circle-progress-danger');
                                            $('#loading').html('');
                                            $('#sfhtml').html(html);
                                            clearInterval(timer10);
                                            notice.msg('检测完成，该环境不符合安装条件！', {icon: 2,audio:'1'});
                                            $("#stepButton").css('display','inherit');
                                        }
                                    }
                                }, 20);
                            }else{
                                notice.msg(data.msg, {icon: 2,audio:'1'});
                            }
                        }
                    });
                }
            }, 600);
            return false;
        });

        // 获取验证码
        form.on('submit(stepDemoFormSubmit2)', function (data) {
            admin.showLoading('#divLoading2', 3, '.8');
            admin.btnLoading('[lay-filter="stepDemoFormSubmit2"]');
            $.ajax({
                type: "POST",
                url: "{:url('/Ajax/check')}",
                dataType: "json",
                success: function(data) {
                    admin.removeLoading('#divLoading2', true, true);
                    admin.btnLoading('[lay-filter="stepDemoFormSubmit2"]', false);
                    if (data.code == 0) {
                        if(data.data.safe != 100){
                            if(data.data.safe >= 90) {
                                layer.confirm('确定要继续安装吗？目前该环境并不完全符合程序运行！', {
                                    skin: 'layui-layer-admin',
                                    icon: 3,
                                    shade: .1
                                }, function (i) {
                                    layer.close(i);
                                    steps.next('stepsDemoForget');
                                    $('#SF_title').html('填写数据库信息');
                                });
                            }else{
                                notice.msg('该环境不符合安装条件！', {icon: 2,audio:'1'});
                            }
                        }else{
                            steps.next('stepsDemoForget');
                            $('#SF_title').html('填写数据库信息');
                        }
                    }else{
                        notice.msg('服务器错误！', {icon: 2,audio:'1'});
                    }
                },
                error: function() {
                    notice.destroy();
                    notice.msg("服务器错误！", {icon: 2, audio:'1'});
                }
            });
        });


        form.on('submit(stepDemoFormSubmit3)', function (data) {
            admin.showLoading('#divLoading3', 3, '.8');
            admin.btnLoading('[lay-filter="stepDemoFormSubmit3"]');
            var data = data.field;
            if(data.hostname == ''){
                admin.removeLoading('#divLoading3', true, true);
                admin.btnLoading('[lay-filter="stepDemoFormSubmit3"]', false);
                notice.msg('请填写数据库地址！', {icon: 3,audio:'1'});
                return false;
            }
            if(data.hostport == ''){
                admin.removeLoading('#divLoading3', true, true);
                admin.btnLoading('[lay-filter="stepDemoFormSubmit3"]', false);
                notice.msg('请填写数据库端口！', {icon: 3,audio:'1'});
                return false;
            }
            if(data.username == ''){
                admin.removeLoading('#divLoading3', true, true);
                admin.btnLoading('[lay-filter="stepDemoFormSubmit3"]', false);
                notice.msg('请填写数据库用户名！', {icon: 3,audio:'1'});
                return false;
            }
            if(data.password == ''){
                admin.removeLoading('#divLoading3', true, true);
                admin.btnLoading('[lay-filter="stepDemoFormSubmit3"]', false);
                notice.msg('请填写数据库密码！', {icon: 3,audio:'1'});
                return false;
            }
            if(data.database == ''){
                admin.removeLoading('#divLoading3', true, true);
                admin.btnLoading('[lay-filter="stepDemoFormSubmit3"]', false);
                notice.msg('请填写数据库库名！', {icon: 3,audio:'1'});
                return false;
            }
            $.ajax({
                type: "POST",
                url: "{:url('/Ajax/install')}",
                data : data,
                dataType: "json",
                success: function(data) {
                    admin.removeLoading('#divLoading3', true, true);
                    admin.btnLoading('[lay-filter="stepDemoFormSubmit3"]', false);
                    if (data.code == 0) {
                        steps.next('stepsDemoForget');
                        notice.msg(data.msg, {icon: 1,audio:'1'});
                        $('#SF_title').html('创建数据表');
                        if(data.data.type == 1){
                            $('#mysql_new').css('display','inherit');
                            $('#mysql_old').css('display','none');
                        }else{
                            $('#mysql_new').css('display','none');
                            $('#mysql_old').css('display','inherit');
                        }
                    } else {
                        notice.msg(data.msg, {icon: 2,audio:'1'});
                    }
                },
                error: function() {
                    notice.destroy();
                    notice.msg("服务器错误！", {icon: 2, audio:'1'});
                }
            });

            return false;
        });

        form.on('submit(jump_install)', function (data) {
            admin.showLoading('#divLoading4', 3, '.8');
            admin.btnLoading('[lay-filter="jump_install"]');
            steps.next('stepsDemoForget');
            steps.next('stepsDemoForget');
            $('#SF_title').html('完成安装');
            admin.removeLoading('#divLoading4', true, true);
            admin.btnLoading('[lay-filter="jump_install"]', false);
            $.ajax({
                type: "GET",
                url: "{:url('/Ajax/putInstallLock')}",
                dataType: "json",
                success: function(data) {
                    if (data.code == 0) {
                        notice.msg('恭喜您，安装程序成功！', {icon: 1,audio:'1'});
                        $('#SF_user').html(data.user);
                        $('#SF_pwd').html(data.pwd);
                        $('#SF_qq').html(data.qq);
                    } else {
                        notice.msg('安装锁未创建成功，请您手动在install目录下创建SF_auth.lock！', {icon: 2,audio:'1'});
                    }
                },
                error: function() {
                    notice.destroy();
                    notice.msg("服务器错误！", {icon: 2, audio:'1'});
                }
            });

        });

        form.on('submit(must_install)', function (data) {
            layer.confirm('全新安装将会清空所有数据，是否继续？', {
                btn: ['是','否'],
                skin: 'layui-layer-admin',
                icon: 3,
                closeBtn:0,
                shade: .1
            }, function (i) {
                layer.close(i);
                admin.showLoading('#divLoading4', 3, '.8');
                admin.btnLoading('[lay-filter="must_install"]');
                $.ajax({
                    type: "POST",
                    url: "{:url('/Ajax/importSQL')}",
                    dataType: "json",
                    success: function(data) {
                        if (data.code == 0) {
                            admin.removeLoading('#divLoading4', true, true);
                            admin.btnLoading('[lay-filter="must_install"]', false);
                            steps.next('stepsDemoForget');
                            notice.msg(data.msg, {icon: 1,audio:'1'});
                            $('#SF_title').html('填写管理员信息');
                            var qqbindingcheck = setInterval(function() {
                                $.ajax({
                                    type: "POST",
                                    url: "{:url('/Ajax/bindingCheck')}",
                                    dataType: "json",
                                    success: function(data) {
                                        var binding=document.getElementById("binding");
                                        if (data.code == 0) {
                                            binding.setAttribute("class","layui-btn layui-btn-SF-green layui-btn-fluid layui-btn-radius");
                                            $("#binding").html('已绑定QQ快捷登录');
                                            clearInterval(qqbindingcheck);
                                        } else {
                                            binding.setAttribute("class","layui-btn layui-btn-warm layui-btn-fluid layui-btn-radius");
                                            $("#binding").html('点击绑定QQ快捷登陆');
                                        }
                                    }
                                });
                            },3000);
                        } else {
                            admin.removeLoading('#divLoading4', true, true);
                            admin.btnLoading('[lay-filter="must_install"]', false);
                            notice.msg(data.msg, {icon: 2,audio:'1'});
                            $('[lay-filter="must_install"]').html('点击重试');
                        }
                    },
                    error: function() {
                        notice.destroy();
                        notice.msg("服务器错误！", {icon: 2, audio:'1'});
                    }
                });

            });
            return false;
        });
        form.on('submit(mysql_install)', function (data) {
            admin.showLoading('#divLoading4', 3, '.8');
            admin.btnLoading('[lay-filter="mysql_install"]');
            $.ajax({
                type: "POST",
                url: "{:url('/Ajax/importSQL')}",
                dataType: "json",
                success: function(data) {
                    if (data.code == 0) {
                        admin.removeLoading('#divLoading4', true, true);
                        admin.btnLoading('[lay-filter="mysql_install"]', false);
                        steps.next('stepsDemoForget');
                        notice.msg(data.msg, {icon: 1,audio:'1'});
                        $('#SF_title').html('填写管理员信息');
                    } else {
                        admin.removeLoading('#divLoading4', true, true);
                        admin.btnLoading('[lay-filter="mysql_install"]', false);
                        notice.msg(data.msg, {icon: 2,audio:'1'});
                        $('[lay-filter="mysql_install"]').html('点击重试');
                    }
                },
                error: function() {
                    notice.destroy();
                    notice.msg("服务器错误！", {icon: 2, audio:'1'});
                }
            });

            return false;
        });

        form.on('submit(admin_info)', function (data) {
            admin.showLoading('#divLoading5', 3, '.8');
            admin.btnLoading('[lay-filter="admin_info"]');
            var data = data.field;
            if(data.admin_username == ''){
                admin.removeLoading('#divLoading5', true, true);
                admin.btnLoading('[lay-filter="admin_info"]', false);
                notice.msg('请填写管理员账号！', {icon: 3,audio:'1'});
                return false;
            }
            if(data.admin_password == ''){
                admin.removeLoading('#divLoading5', true, true);
                admin.btnLoading('[lay-filter="admin_info"]', false);
                notice.msg('请填写管理员密码！', {icon: 3,audio:'1'});
                return false;
            }
            if(data.admin_qq == ''){
                admin.removeLoading('#divLoading5', true, true);
                admin.btnLoading('[lay-filter="admin_info"]', false);
                notice.msg('请填写管理员QQ！', {icon: 3,audio:'1'});
                return false;
            }
            if(data.admin_email == ''){
                admin.removeLoading('#divLoading5', true, true);
                admin.btnLoading('[lay-filter="admin_info"]', false);
                notice.msg('请填写管理员邮箱！', {icon: 3,audio:'1'});
                return false;
            }
            if(data.sitename==''){
                admin.removeLoading('#divLoading5', true, true);
                admin.btnLoading('[lay-filter="admin_info"]', false);
                notice.msg('请填写站点名称！', {icon: 3,audio:'1'});
                return false;
            }
            $.ajax({
                type: "POST",
                url: "{:url('/Ajax/adminInfo')}",
                data : data,
                dataType: "json",
                success: function(data) {
                    if (data.code == 0) {
                        admin.removeLoading('#divLoading5', true, true);
                        admin.btnLoading('[lay-filter="admin_info"]', false);
                        steps.next('stepsDemoForget');
                        notice.msg(data.msg, {icon: 1,audio:'1'});
                        $('#SF_title').html('完成安装');
                        $.ajax({
                            type: "POST",
                            url: "{:url('/Ajax/putInstallLock')}",
                            dataType: "json",
                            success: function(data) {
                                if (data.code == 0) {
                                    notice.msg('恭喜您，安装程序成功！', {icon: 1,audio:'1'})
                                } else {
                                    notice.msg('安装锁未创建成功，请您手动在install目录下创建SF_Auth.Lock！', {icon: 2,audio:'1'});
                                }
                            }
                        });
                    } else {
                        admin.removeLoading('#divLoading5', true, true);
                        admin.btnLoading('[lay-filter="admin_info"]', false);
                        notice.msg(data.msg, {icon: 2,audio:'1'});
                        $('[lay-filter="admin_info"]').html('点击重试');
                    }
                },
                error: function() {
                    notice.destroy();
                    notice.msg("服务器错误！", {icon: 2, audio:'1'});
                }
            });

            return false;
        });

        form.on('submit(SFindex)', function (data) {
            admin.showLoading('#divLoading6', 3, '.8');
            admin.btnLoading('[lay-filter="SFindex"]');
            window.open("/");
            return false;
        });

        form.on('submit(loginadmin)', function (data) {
            admin.showLoading('#divLoading6', 3, '.8');
            admin.btnLoading('[lay-filter="loginadmin"]');
            $.ajax({
                type: "POST",
                url: "{:url('/Login/index')}",
                dataType: "json",
                success: function(data) {
                    admin.removeLoading('#divLoading6', true, true);
                    admin.btnLoading('[lay-filter="loginadmin"]', false);
                    if (data.code == 0) {
                        window.open(data.data.url);
                    } else {
                        notice.msg('获取后台入口失败，请手动跳转！', {icon: 2,audio:'1'});
                    }
                },
                error: function() {
                    admin.removeLoading('#divLoading6', true, true);
                    admin.btnLoading('[lay-filter="loginadmin"]', false);
                    notice.msg("服务器错误！", {icon: 2, audio:'1'});
                }
            });
            return false;
        });
    });
</script>